using UnityEngine;

namespace Crosstales.Common.Util
{
    // [Assembly-CSharp-firstpass.dll].Crosstales.Common.Util.XmlHelper
    public abstract class XmlHelper
    {
        // Methods
        public static void SerializeToFile<T>(T obj, string filename)
        {
            System.ArgumentNullException val_3;
            string val_4;
            if(obj == null)
            {
                goto label_0;
            }
            
            if(filename == null)
            {
                goto label_1;
            }
            
            System.IO.File.WriteAllText(path:  filename, contents:  obj);
            return;
            label_0:
            val_3 = 27342272;
            val_4 = 27541576;
            goto label_2;
            label_1:
            val_3 = 27342272;
            val_4 = 27534432;
            label_2:
            val_3 = new System.ArgumentNullException(paramName:  val_4);
            throw val_3;
        }
        public static string SerializeToString<T>(T obj)
        {
            if(obj != null)
            {
                    if(obj == null)
            {
                    return (string)mem[536893213];
            }
            
                System.Text.Encoding val_1 = System.Text.Encoding.UTF8;
                __RuntimeMethodHiddenParam = ???;
            }
            else
            {
                    27342272 = new System.ArgumentNullException(paramName:  27541576);
                throw 27342272;
            }
        
        }
        public static byte[] SerializeToByteArray<T>(T obj)
        {
            System.IO.MemoryStream val_10;
            System.Type val_11;
            if(obj != null)
            {
                    val_10 = 536889459;
                if(val_10 == 0)
            {
                    throw new NullReferenceException();
            }
            
                val_10 = new System.IO.MemoryStream();
                val_11 = mem[__RuntimeMethodHiddenParam + 56 + 8];
                val_11 = __RuntimeMethodHiddenParam + 56 + 8;
                val_10 = 536896733;
                if(val_10 == 0)
            {
                    throw new NullReferenceException();
            }
            
                val_11 = obj.GetType();
                val_10 = new System.Xml.Serialization.XmlSerializer(type:  val_11);
                val_10 = 536896781;
                if(val_10 == 0)
            {
                    throw new NullReferenceException();
            }
            
                val_10 = new System.Xml.XmlTextWriter(w:  val_10, encoding:  System.Text.Encoding.UTF8);
                val_10.Serialize(xmlWriter:  val_10, o:  obj);
                return (Unknown)val_10.BaseStream;
            }
            
            27342272 = new System.ArgumentNullException(paramName:  27541576);
            val_11 = 27466288;
            val_10 = 27342272;
            throw val_10;
        }
        public static T DeserializeFromFile<T>(string filename, bool skipBOM = False)
        {
            var val_9;
            var val_10;
            if(filename == null)
            {
                goto label_1;
            }
            
            if((System.IO.File.Exists(path:  filename)) == false)
            {
                goto label_2;
            }
            
            string val_2 = System.IO.File.ReadAllText(path:  filename);
            val_9 = val_2;
            if((System.String.IsNullOrEmpty(value:  val_2)) == false)
            {
                goto label_3;
            }
            
            UnityEngine.Debug.LogWarning(message:  -1610608269(-1610608269) + filename);
            val_10 = 0;
            return (Unknown)val_10;
            label_2:
            UnityEngine.Debug.LogError(message:  -1610607461(-1610607461) + filename);
            val_10 = 0;
            return (Unknown)val_10;
            label_3:
            bool val_6 = skipBOM;
            val_10 = val_9;
            return (Unknown)val_10;
            label_1:
            27342272 = new System.ArgumentNullException(paramName:  27534432);
            throw 27342272;
        }
        public static T DeserializeFromString<T>(string xmlAsString, bool skipBOM = True)
        {
            object val_7;
            System.Xml.Serialization.XmlSerializer val_12;
            var val_13;
            string val_14;
            System.Type val_15;
            var val_16;
            var val_17;
            var val_18;
            var val_19;
            var val_20;
            var val_21;
            var val_22;
            val_13 = __RuntimeMethodHiddenParam;
            val_14 = xmlAsString;
            if((System.String.IsNullOrEmpty(value:  val_14)) == true)
            {
                goto label_1;
            }
            
            val_15 = System.Type.GetTypeFromHandle(handle:  new System.RuntimeTypeHandle() {value = __RuntimeMethodHiddenParam + 56});
            val_12 = 536896733;
            if(536896733 == 0)
            {
                    throw new NullReferenceException();
            }
            
            val_12 = new System.Xml.Serialization.XmlSerializer(type:  val_15);
            if(val_14 == null)
            {
                    throw new NullReferenceException();
            }
            
            val_14 = 536893125;
            val_14 = new System.IO.StringReader(s:  val_14.Trim());
            val_15 = 27348040;
            val_12 = val_12.Deserialize(textReader:  val_14);
            val_13 = mem[__RuntimeMethodHiddenParam + 56 + 8];
            val_13 = __RuntimeMethodHiddenParam + 56 + 8;
            if(((__RuntimeMethodHiddenParam + 56 + 8 + 306) & 1) == 0)
            {
                    val_13 = val_13;
            }
            
            if(val_12 == null)
            {
                goto label_8;
            }
            
            val_16 = X0;
            if(X0 == false)
            {
                goto label_9;
            }
            
            val_17 = 0;
            goto label_10;
            label_8:
            val_17 = 0;
            val_16 = 0;
            label_10:
            val_12 = 6;
            label_29:
            var val_12 = mem[536893125];
            var val_11 = mem[536893125] + 298;
            if(val_11 == 0)
            {
                goto label_11;
            }
            
            var val_10 = mem[536893125] + 176;
            val_10 = val_10 + 8;
            label_13:
            if(((mem[536893125] + 176 + 8) + -8) == 536887297)
            {
                goto label_12;
            }
            
            val_11 = val_11 - 1;
            val_10 = val_10 + 16;
            if(((mem[536893125] + 176 + 8) + -8) != 536887297)
            {
                goto label_13;
            }
            
            label_11:
            val_18 = val_14;
            goto label_14;
            label_12:
            val_12 = val_12 + (((mem[536893125] + 176 + 8)) << 4);
            val_18 = val_12 + 312;
            label_14:
            if(val_17 != 0)
            {
                goto label_15;
            }
            
            if(6 != 0)
            {
                    return (Unknown)val_16;
            }
            
            val_19 = 0;
            label_27:
            UnityEngine.Debug.LogError(message:  System.String.Format(format:  27495064, arg0:  val_7));
            val_16 = 0;
            return (Unknown)val_16;
            label_1:
            val_14 = 27342272;
            val_14 = new System.ArgumentNullException(paramName:  27549448);
            throw val_14;
            label_15:
            label_9:
            val_20 = val_13;
            val_21 = 28168192;
            label_34:
            if(val_20 != 1)
            {
                goto label_25;
            }
            
            val_14 = val_21;
            if((27346264 & 1) == 0)
            {
                goto label_26;
            }
            
            val_7 = 0;
            goto label_27;
            label_26:
            mem[8] = 0;
            val_20 = 26159128;
            val_21 = 8;
            label_25:
            if(val_20 != 1)
            {
                goto label_28;
            }
            
            goto label_29;
            label_28:
            label_35:
            var val_13 = 399;
            if(val_13 == 0)
            {
                goto label_30;
            }
            
            var val_14 = 25769803786;
            label_32:
            if(mem[25769803778] == X23)
            {
                goto label_31;
            }
            
            val_13 = val_13 - 1;
            val_14 = val_14 + 16;
            if(mem[25769803778] != X23)
            {
                goto label_32;
            }
            
            label_30:
            val_22 = val_14;
            goto label_33;
            label_31:
            val_14 = val_14 + ((mem[25769803786]) << 4);
            val_22 = val_14 + 312;
            label_33:
            if(0 == 0)
            {
                goto label_34;
            }
            
            goto label_35;
        }
        public static T DeserializeFromByteArray<T>(byte[] data)
        {
            Unknown val_7;
            var val_8;
            System.Xml.Serialization.XmlSerializer val_9;
            var val_10;
            var val_11;
            val_7 = data;
            if(val_7 == null)
            {
                goto label_1;
            }
            
            val_8 = 0;
            val_9 = 536896733;
            if(val_9 == 0)
            {
                    throw new NullReferenceException();
            }
            
            val_9 = new System.Xml.Serialization.XmlSerializer(type:  System.Type.GetTypeFromHandle(handle:  new System.RuntimeTypeHandle() {value = __RuntimeMethodHiddenParam + 56}));
            536889459 = new System.IO.MemoryStream(buffer:  val_7);
            val_7 = val_9.Deserialize(stream:  536889459);
            val_10 = mem[__RuntimeMethodHiddenParam + 56 + 8];
            val_10 = __RuntimeMethodHiddenParam + 56 + 8;
            if(((__RuntimeMethodHiddenParam + 56 + 8 + 306) & 1) == 0)
            {
                    val_10 = val_10;
            }
            
            if(val_7 == null)
            {
                goto label_6;
            }
            
            if(X0 == true)
            {
                    return (Unknown)val_11;
            }
            
            label_1:
            27342272 = new System.ArgumentNullException(paramName:  27531864);
            val_8 = 27466256;
            val_9 = 27342272;
            throw val_9;
            label_6:
            val_11 = 0;
            return (Unknown)val_11;
        }
        public static T DeserializeFromResource<T>(string resourceName, bool skipBOM = True)
        {
            var val_12;
            var val_13;
            val_12 = __RuntimeMethodHiddenParam;
            string val_12 = resourceName;
            if((System.String.IsNullOrEmpty(value:  val_12)) != true)
            {
                    UnityEngine.Object val_2 = UnityEngine.Resources.Load(path:  val_12);
                val_13 = 0;
                if( == 0)
            {
                    return 0;
            }
            
                string val_4 = text;
                bool val_5 = skipBOM;
                val_12 = ???;
            }
            else
            {
                    27342272 = new System.ArgumentNullException(paramName:  27543248);
                throw 27342272;
            }
        
        }
        protected XmlHelper()
        {
        
        }
    
    }

}
